#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;  
#define maxn 1000005  
#define LL long long   
const LL INF=92233720368548000;  
int c[maxn],n;  
string s[maxn][2];  
LL dp[maxn][2];     
inline int read(){
    int x=0,w=1;char ch;
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') w=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch-48),ch=getchar();
    return x*w;
}
string rev(string s) {  
    string res=s;  
    int len=res.length();  
    for(register int i=0;i<len/2;++i)  swap(res[i],res[len-1-i]);  
    return res;  
}
int main() {
   // freopen("hard.in","r",stdin);
//    freopen("hard.out","w",stdout);
    scanf("%lld",&n);
    for(register int i=0;i<n;++i) scanf("%lld",&c[i]);
    for(register int i=0;i<n;++i) {cin>>s[i][0];s[i][1]=rev(s[i][0]); }  
    for(register int i=0;i<n;++i) dp[i][0]=dp[i][1]=INF;  
        dp[0][0]=0; dp[0][1]=c[0];  
        for(register int i=1;i<n;++i) {  
            if(s[i][0]>=s[i-1][0])  dp[i][0]=dp[i-1][0];  
            if(s[i][1]>=s[i-1][0])  dp[i][1]=dp[i-1][0]+c[i];  
            if(s[i][0]>=s[i-1][1])  dp[i][0]=min(dp[i][0],dp[i-1][1]);  
            if(s[i][1]>=s[i-1][1])  dp[i][1]=min(dp[i][1],dp[i-1][1]+c[i]);  
            if(dp[i][1]==INF&&dp[i][0]==INF) {printf("-1");return 0;};  
        }  
    printf("%lld\n",min(dp[n-1][0],dp[n-1][1]));
    return 0;  
}
